implimented strategy pattern for start and finish flow#1036
implimented strategy pattern for start and finish flow#1036Mental-Block wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the authentication flow system by implementing the strategy pattern to replace if/else conditionals with function maps for both start and finish flows across different authentication methods (OIDC, Mail OTP, Mail Link, PassKey).
- Replaces lengthy if/else chains with strategy pattern using function maps
- Adds new OIDC constant and improves code organization
- Extracts authentication logic into dedicated strategy functions
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| core/authenticate/strategy/oidc.go | Adds OIDCAuthMethod constant for strategy pattern |
| core/authenticate/service.go | Major refactoring to implement strategy pattern with function maps and extract flow logic |
| core/authenticate/authenticate.go | Imports OIDC constant from strategy package |
Comments suppressed due to low confidence (1)
| PassKeyAuthMethod.String(): finishKeyPassFlow, | ||
| MailOTPAuthMethod.String(): finishMailOTPFlow, | ||
| MailLinkAuthMethod.String(): finishMailLinkFlow, | ||
| OIDCAuthMethod.String(): finishOCIDFlow, |
There was a problem hiding this comment.
Function name 'finishOCIDFlow' has a typo. Should be 'finishOIDCFlow' to match the OIDC naming convention.
| return finishMailOTPFlow(s, ctx, request) | ||
| } | ||
|
|
||
| func finishOCIDFlow(s Service, ctx context.Context, request RegistrationFinishRequest) (*RegistrationFinishResponse, error) { |
There was a problem hiding this comment.
Function name 'finishOCIDFlow' has a typo. Should be 'finishOIDCFlow' to match the OIDC naming convention.
| return finishMailOTPFlow(s, ctx, request) | |
| } | |
| func finishOCIDFlow(s Service, ctx context.Context, request RegistrationFinishRequest) (*RegistrationFinishResponse, error) { | |
| return finishOIDCFlow(s, ctx, request) | |
| } | |
| func finishOIDCFlow(s Service, ctx context.Context, request RegistrationFinishRequest) (*RegistrationFinishResponse, error) { |
|
Closing this for now, we might plan to try refactoring this later. |
removed a bunch of if statements in flow in favour of implementing strategy pattern for different auth flow methods. all passes test.